package com.campus.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.campus.pojos.domain.ClientComment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;

@Mapper
public interface CommentMapper extends BaseMapper<ClientComment> {

    /**
     * 查询帖子评论
     * @param id
     * @return
     */
    @Select("select * from client_comment where article_id =#{id}")
    ClientComment getById(Integer id);

    /**
     * 删除帖子评论
     * @param id
     * @return
     */
    @Delete("delete from client_comment where id=#{id}")
    void deleteById(Integer id);

    /**
     * 添加评论
     * @param clientComment
     * @return
     */
    @Insert("insert into client_comment (user_id, article_id, comment_context, create_time, update_time)" +
            "values (#{userId},#{articleId},#{commentContext},#{createTime},#{updateTime})")
    void add(ClientComment clientComment);
}
